<?php

use App\Enums\EnableStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin', function (Blueprint $table) {
            $table->id();
            $table->string('username', 100)->comment('管理员账号');
            $table->string('name')->comment('姓名');
            $table->boolean('super_admin')->default(false)->comment('是否为超级管理员');
            $table->string('password')->comment('密码');
            $table->boolean('enable_status')->default(EnableStatus::ENABLE)->comment('是否可用');
            $table->string('mobile', 11)->comment('绑定手机号码');
            $table->ipAddress('last_login_ip')->nullable()->comment('最后一次登录IP');
            $table->timestamp('last_login_time')->nullable()->comment('最后一次登录时间');
            $table->softDeletes('deleted_at');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin');
    }
}
